import 'dart:io';

import 'package:snooperlang/src/snooperParser.dart';
import 'package:snooperlang/src/snooperParsersym.dart';

class AstDumper extends AbstractVisitor {
  @override
  void visitASTNodeToken(ASTNodeToken n, [Object? o]) {
    var kind = n.getLeftIToken().getKind();
    if (kind == snooperParsersym.TK_CRLF) {
      return;
    }
    String prefix = o as String;

    stdout.writeln(prefix + "Token:");
    stdout.writeln(prefix + "  内容:" + n.toString());
    stdout.writeln(
        prefix + "  类型:" + snooperParsersym.orderedTerminalSymbols[kind]);
  }

  @override
  void print(ASTNode n, [Object? o]) {
    String prefix = o as String;

    stdout.write(prefix);
    stdout.writeln(snooperParsersym.orderedRuleNames[n.getRuleIndex()] + ':');
    var children = n.getChildren();
    for (var i = 0; i < children.size(); ++i) {
      ASTNode child = children.get(i);
      visit(child, prefix + "  ");
    }
  }

  @override
  @override
  void unimplementedVisitor(String s) {
    throw ArgumentError(s);
  }

  @override
  void visitSnooperProg(SnooperProg n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSnooperSegmentItemList(SnooperSegmentItemList n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitReturnStmt(ReturnStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitFunctionDecl(FunctionDecl n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitStatementList_StatementList(StatementList_StatementList n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitStatementList(StatementList n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitIfSeg(IfSeg n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitIfThenStatement(IfThenStatement n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitElseSeg(ElseSeg n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitIfThenElseStatement(IfThenElseStatement n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitElseIfStatementItemList(ElseIfStatementItemList n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitElseIfStatementItem(ElseIfStatementItem n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitVariable(Variable n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitBadVariable(BadVariable n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitLetOpt(LetOpt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitVariableStmt(VariableStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitPrimaryAssignmentStmt(PrimaryAssignmentStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitArrayAccesOnLeftSide(ArrayAccesOnLeftSide n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitArrayAccessAssignmentStmt(ArrayAccessAssignmentStmt n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitKeywordAssignmentStmt(KeywordAssignmentStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitBadAssignment(BadAssignment n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitDoLoopStmt(DoLoopStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitStepStmOpt(StepStmOpt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitForStmt(ForStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitNextSeg(NextSeg n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitHforStmt(HforStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitHnexSeg(HnexSeg n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitNumberLiteral(NumberLiteral n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitStringLiteral(StringLiteral n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitArrayAccess(ArrayAccess n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitHexMacroPrimary(HexMacroPrimary n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitApduDataWith3Lc(ApduDataWith3Lc n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitApduDataWith2Lc(ApduDataWith2Lc n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitApduDataWith4Lc(ApduDataWith4Lc n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitApduDataWithoutLc(ApduDataWithoutLc n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitApduDataList(ApduDataList n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitPostIncrementExpression(PostIncrementExpression n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitPostDecrementExpression(PostDecrementExpression n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitPreIncrementExpression(PreIncrementExpression n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitPreDecrementExpression(PreDecrementExpression n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitUnaryExpNotPlusMinus_Xor(UnaryExpNotPlusMinus_Xor n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitUnaryExpNotPlusMinus_Not(UnaryExpNotPlusMinus_Not n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitMultiplicativeExp_Divide(MultiplicativeExp_Divide n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitMultiplicativeExp_Multiply(MultiplicativeExp_Multiply n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitMultiplicativeExp_Remainder(MultiplicativeExp_Remainder n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitAdditiveExp_Plus(AdditiveExp_Plus n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitAdditiveExp_Minus(AdditiveExp_Minus n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitShiftExp_Left(ShiftExp_Left n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitShiftExp_Right(ShiftExp_Right n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitRelationalExp_Less(RelationalExp_Less n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitRelationalExp_Greater(RelationalExp_Greater n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitRelationalExp_LessEqual(RelationalExp_LessEqual n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitRelationalExp_GreaterEqual(RelationalExp_GreaterEqual n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitEqualityExpr_EqualEqual(EqualityExpr_EqualEqual n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitEqualityExpr_NotEqual(EqualityExpr_NotEqual n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitAndExpression(AndExpression n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitExclusiveOrExpression(ExclusiveOrExpression n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitInclusiveOrExpression(InclusiveOrExpression n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitConditionalAndExpression(ConditionalAndExpression n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitConditionalOrExpression(ConditionalOrExpression n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitExpressionStmt(ExpressionStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitVariableAndSW(VariableAndSW n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitExpressionList(ExpressionList n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitCallOpt(CallOpt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitFunctionCall(FunctionCall n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitExitForStatement(ExitForStatement n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitExitHforStatement(ExitHforStatement n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitLoadOption_load_script(LoadOption_load_script n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitLoadOption_loadprofile(LoadOption_loadprofile n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitLoadOption_run_script(LoadOption_run_script n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitLoadScriptStmt(LoadScriptStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_timer_begin(SimpleOption_timer_begin n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_timer_end(SimpleOption_timer_end n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_pause(SimpleOption_pause n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_file(SimpleOption_file n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_line(SimpleOption_line n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_clear_fifo(SimpleOption_clear_fifo n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_beep(SimpleOption_beep n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_eject(SimpleOption_eject n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_insert(SimpleOption_insert n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_split(SimpleOption_split n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_end(SimpleOption_end n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSimpleOption_clear(SimpleOption_clear n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitKeyWordWithoutParameterStmt(KeyWordWithoutParameterStmt n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitSleepStmt(SleepStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSetStmt_Identifier(SetStmt_Identifier n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSetStmt_MacroName(SetStmt_MacroName n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitPrintStmt_Message(PrintStmt_Message n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitPrintStmt_Quqstion(PrintStmt_Quqstion n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitOnOffOption_on(OnOffOption_on n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitOnOffOption_off(OnOffOption_off n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitAutoResponseStmt(AutoResponseStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitWriteFifoStmt_Identifier(WriteFifoStmt_Identifier n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitWriteFifoStmt_MacroName(WriteFifoStmt_MacroName n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitUploadStmt_upload(UploadStmt_upload n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitUploadStmt_upload2(UploadStmt_upload2 n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitResetStmt_reset(ResetStmt_reset n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitResetStmt_reset2(ResetStmt_reset2 n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitResetStmt_reset_cold(ResetStmt_reset_cold n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitResetStmt_reset2_cold(ResetStmt_reset2_cold n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitInstallParameterList(InstallParameterList n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitInstallStmt_install(InstallStmt_install n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitInstallStmt_install_2(InstallStmt_install_2 n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitParameterItem(ParameterItem n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitParameterItemList(ParameterItemList n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitJcopAuthStmt_jcop22_ext_auth(JcopAuthStmt_jcop22_ext_auth n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitJcopAuthStmt_jcop22_ext_auth_kmc(JcopAuthStmt_jcop22_ext_auth_kmc n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitJcopAuthStmt_jcop22_ext_auth_2(JcopAuthStmt_jcop22_ext_auth_2 n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitJcopAuthStmt_jcop22_ext_auth_kmc_2(
      JcopAuthStmt_jcop22_ext_auth_kmc_2 n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitJcopAuthStmt_jcop22_ext_auth_nonblock(
      JcopAuthStmt_jcop22_ext_auth_nonblock n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitSelectStmt_select(SelectStmt_select n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSelectStmt_select_2(SelectStmt_select_2 n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitDeleteStmt_delete(DeleteStmt_delete n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitDeleteStmt_delete_2(DeleteStmt_delete_2 n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitApdu2Stmt(Apdu2Stmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitPromptStmt(PromptStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitShowapduStmt(ShowapduStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitDes_3des_mac_call(Des_3des_mac_call n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitDes_3des_mac_Stmt(Des_3des_mac_Stmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitFull_3des_mac_call(Full_3des_mac_call n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitFull_3des_mac_Stmt(Full_3des_mac_Stmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitMac_auto_mac_option(Mac_auto_mac_option n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitMac_auto_mac_option2(Mac_auto_mac_option2 n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitMac_auto_mac_Stmt(Mac_auto_mac_Stmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitLineEndOpt(LineEndOpt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSuperlongStmtInOneLine(SuperlongStmtInOneLine n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSuperlongStmtInMutipleLines(SuperlongStmtInMutipleLines n,
      [Object? o]) {
    print(n, o);
  }

  @override
  void visitCompareStmt(CompareStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSocket_messageStmt(Socket_messageStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitGenerateStmt(GenerateStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitSendtextStmt(SendtextStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitPushStmt(PushStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitGotoStmt(GotoStmt n, [Object? o]) {
    print(n, o);
  }

  @override
  void visitEmptyStatement0(EmptyStatement0 n, [Object? o]) {
    // print(n,o);
  }

  @override
  void visitEmptyStatement1(EmptyStatement1 n, [Object? o]) {
    // print(n,o);
  }

  @override
  void visitCallSignature(CallSignature n, [Object? o]) {
    print(n, o);
  }

  Object? visitSimpleName(SimpleName n, [Object? o]) {
    print(n, o);
  }

  Object? visitSimpleNameList(SimpleNameList n, [Object? o]) {
    print(n, o);
  }
}
